package com.example.xt.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.xt.common.Result;
import com.example.xt.entity.Orders;
import com.example.xt.entity.Rder;
import com.example.xt.service.IOrdersService;
import com.example.xt.service.IRderService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-03-05
 */
@RestController
@RequestMapping("/rder")
public class RderController {
    @Resource
    private IOrdersService ordersService;
    @Resource
    private IRderService rderService;


    @GetMapping("/{medicine}")
    public List<Rder> findOne(@PathVariable Integer medicine) {
        return rderService.get(medicine);
    }

    @PostMapping("/{medicine}")//退货
    public Result rent(@PathVariable Integer medicine) {
        return Result.success(rderService.rent(medicine));
    }

    @GetMapping("/page")
    public Page<Orders> findPage(@RequestParam Integer pageNum,
                                 @RequestParam Integer pageSize) {
        return ordersService.page(new Page<>(pageNum, pageSize));
    }


}

